home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / perlfaq1.z / perlfaq1
Text File  |  1998-10-30  |  19KB  |  397 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))                                                        PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      perlfaq1 - General Questions About Perl ($Revision: 1.12 $, $Date:
  10.      1997/04/24 22:43:34 $)
  11.  
  12. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  13.      This section of the FAQ answers very general, high-level questions about
  14.      Perl.
  15.  
  16.      WWWWhhhhaaaatttt iiiissss PPPPeeeerrrrllll????
  17.  
  18.      Perl is a high-level programming language with an eclectic heritage
  19.      written by Larry Wall and a cast of thousands.  It derives from the
  20.      ubiquitous C programming language and to a lesser extent from sed, awk,
  21.      the Unix shell, and at least a dozen other tools and languages.  Perl's
  22.      process, file, and text manipulation facilities make it particularly
  23.      well-suited for tasks involving quick prototyping, system utilities,
  24.      software tools, system management tasks, database access, graphical
  25.      programming, networking, and world wide web programming.  These strengths
  26.      make it especially popular with system administrators and CGI script
  27.      authors, but mathematicians, geneticists, journalists, and even managers
  28.      also use Perl.  Maybe you should, too.
  29.  
  30.      WWWWhhhhoooo ssssuuuuppppppppoooorrrrttttssss PPPPeeeerrrrllll????  WWWWhhhhoooo ddddeeeevvvveeeellllooooppppssss iiiitttt????  WWWWhhhhyyyy iiiissss iiiitttt ffffrrrreeeeeeee????
  31.  
  32.      The original culture of the pre-populist Internet and the deeply-held
  33.      beliefs of Perl's author, Larry Wall, gave rise to the free and open
  34.      distribution policy of perl.  Perl is supported by its users.  The core,
  35.      the standard Perl library, the optional modules, and the documentation
  36.      you're reading now were all written by volunteers.  See the personal note
  37.      at the end of the README file in the perl source distribution for more
  38.      details.
  39.  
  40.      In particular, the core development team (known as the Perl Porters) are
  41.      a rag-tag band of highly altruistic individuals committed to producing
  42.      better software for free than you could hope to purchase for money.  You
  43.      may snoop on pending developments via
  44.      news://genetics.upenn.edu/perl.porters-gw/ and
  45.      http://www.frii.com/~gnat/perl/porters/summary.html.
  46.  
  47.      While the GNU project includes Perl in its distributions, there's no such
  48.      thing as "GNU Perl".  Perl is not produced nor maintained by the Free
  49.      Software Foundation.  Perl's licensing terms are also more open than GNU
  50.      software's tend to be.
  51.  
  52.      You can get commercial support of Perl if you wish, although for most
  53.      users the informal support will more than suffice.  See the answer to
  54.      "Where can I buy a commercial version of perl?" for more information.
  55.  
  56.      WWWWhhhhiiiicccchhhh vvvveeeerrrrssssiiiioooonnnn ooooffff PPPPeeeerrrrllll sssshhhhoooouuuulllldddd IIII uuuusssseeee????
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))                                                        PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  71.  
  72.  
  73.  
  74.      You should definitely use version 5.  Version 4 is old, limited, and no
  75.      longer maintained; its last patch (4.036) was in 1992.  The most recent
  76.      production release is 5.004.  Further references to the Perl language in
  77.      this document refer to this production release unless otherwise
  78.      specified.  There may be one or more official bug fixes for 5.004 by the
  79.      time you read this, and also perhaps some experimental versions on the
  80.      way to the next release.
  81.  
  82.      WWWWhhhhaaaatttt aaaarrrreeee ppppeeeerrrrllll4444 aaaannnndddd ppppeeeerrrrllll5555????
  83.  
  84.      Perl4 and perl5 are informal names for different versions of the Perl
  85.      programming language.  It's easier to say "perl5" than it is to say "the
  86.      _5(.004) release of Perl", but some people have interpreted this to mean
  87.      there's a language called "perl5", which isn't the case.  Perl5 is merely
  88.      the popular name for the fifth major release (October 1994), while perl4
  89.      was the fourth major release (March 1991).  There was also a perl1 (in
  90.      January 1988), a perl2 (June 1988), and a perl3 (October 1989).
  91.  
  92.      The 5.0 release is, essentially, a complete rewrite of the perl source
  93.      code from the ground up.  It has been modularized, object-oriented,
  94.      tweaked, trimmed, and optimized until it almost doesn't look like the old
  95.      code.  However, the interface is mostly the same, and compatibility with
  96.      previous releases is very high.
  97.  
  98.      To avoid the "what language is perl5?" confusion, some people prefer to
  99.      simply use "perl" to refer to the latest version of perl and avoid using
  100.      "perl5" altogether.  It's not really that big a deal, though.
  101.  
  102.      HHHHoooowwww ssssttttaaaabbbblllleeee iiiissss PPPPeeeerrrrllll????
  103.  
  104.      Production releases, which incorporate bug fixes and new functionality,
  105.      are widely tested before release.  Since the 5.000 release, we have
  106.      averaged only about one production release per year.
  107.  
  108.      Larry and the Perl development team occasionally make changes to the
  109.      internal core of the language, but all possible efforts are made toward
  110.      backward compatibility.  While not quite all perl4 scripts run flawlessly
  111.      under perl5, an update to perl should nearly never invalidate a program
  112.      written for an earlier version of perl (barring accidental bug fixes and
  113.      the rare new keyword).
  114.  
  115.      IIIIssss PPPPeeeerrrrllll ddddiiiiffffffffiiiiccccuuuulllltttt ttttoooo lllleeeeaaaarrrrnnnn????
  116.  
  117.      Perl is easy to start learning -- and easy to keep learning.  It looks
  118.      like most programming languages you're likely to have had experience
  119.      with, so if you've ever written an C program, an awk script, a shell
  120.      script, or even an Excel macro, you're already part way there.
  121.  
  122.      Most tasks only require a small subset of the Perl language.  One of the
  123.      guiding mottos for Perl development is "there's more than one way to do
  124.      it" (TMTOWTDI, sometimes pronounced "tim toady").  Perl's learning curve
  125.      is therefore shallow (easy to learn) and long (there's a whole lot you
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))                                                        PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  137.  
  138.  
  139.  
  140.      can do if you really want).
  141.  
  142.      Finally, Perl is (frequently) an interpreted language.  This means that
  143.      you can write your programs and test them without an intermediate
  144.      compilation step, allowing you to experiment and test/debug quickly and
  145.      easily.  This ease of experimentation flattens the learning curve even
  146.      more.
  147.  
  148.      Things that make Perl easier to learn: Unix experience, almost any kind
  149.      of programming experience, an understanding of regular expressions, and
  150.      the ability to understand other people's code.  If there's something you
  151.      need to do, then it's probably already been done, and a working example
  152.      is usually available for free.  Don't forget the new perl modules,
  153.      either.  They're discussed in Part 3 of this FAQ, along with the CPAN,
  154.      which is discussed in Part 2.
  155.  
  156.      HHHHoooowwww ddddooooeeeessss PPPPeeeerrrrllll ccccoooommmmppppaaaarrrreeee wwwwiiiitttthhhh ooootttthhhheeeerrrr llllaaaannnngggguuuuaaaaggggeeeessss lllliiiikkkkeeee JJJJaaaavvvvaaaa,,,, PPPPyyyytttthhhhoooonnnn,,,, RRRREEEEXXXXXXXX,,,,
  157.      SSSScccchhhheeeemmmmeeee,,,, oooorrrr TTTTccccllll????
  158.  
  159.      Favorably in some areas, unfavorably in others.  Precisely which areas
  160.      are good and bad is often a personal choice, so asking this question on
  161.      Usenet runs a strong risk of starting an unproductive Holy War.
  162.  
  163.      Probably the best thing to do is try to write equivalent code to do a set
  164.      of tasks.  These languages have their own newsgroups in which you can
  165.      learn about (but hopefully not argue about) them.
  166.  
  167.      CCCCaaaannnn IIII ddddoooo [[[[ttttaaaasssskkkk]]]] iiiinnnn PPPPeeeerrrrllll????
  168.  
  169.      Perl is flexible and extensible enough for you to use on almost any task,
  170.      from one-line file-processing tasks to complex systems.  For many people,
  171.      Perl serves as a great replacement for shell scripting.  For others, it
  172.      serves as a convenient, high-level replacement for most of what they'd
  173.      program in low-level languages like C or C++.  It's ultimately up to you
  174.      (and possibly your management ...) which tasks you'll use Perl for and
  175.      which you won't.
  176.  
  177.      If you have a library that provides an API, you can make any component of
  178.      it available as just another Perl function or variable using a Perl
  179.      extension written in C or C++ and dynamically linked into your main perl
  180.      interpreter.  You can also go the other direction, and write your main
  181.      program in C or C++, and then link in some Perl code on the fly, to
  182.      create a powerful application.
  183.  
  184.      That said, there will always be small, focused, special-purpose languages
  185.      dedicated to a specific problem domain that are simply more convenient
  186.      for certain kinds of problems.  Perl tries to be all things to all
  187.      people, but nothing special to anyone.  Examples of specialized languages
  188.      that come to mind include prolog and matlab.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))                                                        PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  203.  
  204.  
  205.  
  206.      WWWWhhhheeeennnn sssshhhhoooouuuullllddddnnnn''''tttt IIII pppprrrrooooggggrrrraaaammmm iiiinnnn PPPPeeeerrrrllll????
  207.  
  208.      When your manager forbids it -- but do consider replacing them :-).
  209.  
  210.      Actually, one good reason is when you already have an existing
  211.      application written in another language that's all done (and done well),
  212.      or you have an application language specifically designed for a certain
  213.      task (e.g. prolog, make).
  214.  
  215.      For various reasons, Perl is probably not well-suited for real-time
  216.      embedded systems, low-level operating systems development work like
  217.      device drivers or context-switching code, complex multithreaded shared-
  218.      memory applications, or extremely large applications.  You'll notice that
  219.      perl is not itself written in Perl.
  220.  
  221.      The new native-code compiler for Perl may reduce the limitations given in
  222.      the previous statement to some degree, but understand that Perl remains
  223.      fundamentally a dynamically typed language, and not a statically typed
  224.      one.  You certainly won't be chastized if you don't trust nuclear-plant
  225.      or brain-surgery monitoring code to it.  And Larry will sleep easier, too
  226.      -- Wall Street programs not withstanding. :-)
  227.  
  228.      WWWWhhhhaaaatttt''''ssss tttthhhheeee ddddiiiiffffffffeeeerrrreeeennnncccceeee bbbbeeeettttwwwweeeeeeeennnn """"ppppeeeerrrrllll"""" aaaannnndddd """"PPPPeeeerrrrllll""""????
  229.  
  230.      One bit.  Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
  231.      signify the language proper and "perl" the implementation of it, i.e. the
  232.      current interpreter.  Hence Tom's quip that "Nothing but perl can parse
  233.      Perl."  You may or may not choose to follow this usage.  For example,
  234.      parallelism means "awk and perl" and "Python and Perl" look ok, while
  235.      "awk and Perl" and "Python and perl" do not.
  236.  
  237.      IIIIssss iiiitttt aaaa PPPPeeeerrrrllll pppprrrrooooggggrrrraaaammmm oooorrrr aaaa PPPPeeeerrrrllll ssssccccrrrriiiipppptttt????
  238.  
  239.      It doesn't matter.
  240.  
  241.      In "standard terminology" a _p_r_o_g_r_a_m has been compiled to physical machine
  242.      code once, and can then be be run multiple times, whereas a _s_c_r_i_p_t must
  243.      be translated by a program each time it's used.  Perl programs, however,
  244.      are usually neither strictly compiled nor strictly interpreted.  They can
  245.      be compiled to a byte code form (something of a Perl virtual machine) or
  246.      to completely different languages, like C or assembly language.  You
  247.      can't tell just by looking whether the source is destined for a pure
  248.      interpreter, a parse-tree interpreter, a byte code interpreter, or a
  249.      native-code compiler, so it's hard to give a definitive answer here.
  250.  
  251.      WWWWhhhhaaaatttt iiiissss aaaa JJJJAAAAPPPPHHHH????
  252.  
  253.      These are the "just another perl hacker" signatures that some people sign
  254.      their postings with.  About 100 of the of the earlier ones are available
  255.      from http://www.perl.com/CPAN/misc/japh .
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))                                                        PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  269.  
  270.  
  271.  
  272.      WWWWhhhheeeerrrreeee ccccaaaannnn IIII ggggeeeetttt aaaa lllliiiisssstttt ooooffff LLLLaaaarrrrrrrryyyy WWWWaaaallllllll wwwwiiiittttttttiiiicccciiiissssmmmmssss????
  273.  
  274.      Over a hundred quips by Larry, from postings of his or source code, can
  275.      be found at http://www.perl.com/CPAN/misc/lwall-quotes .
  276.  
  277.      HHHHoooowwww ccccaaaannnn IIII ccccoooonnnnvvvviiiinnnncccceeee mmmmyyyy ssssyyyyssssaaaaddddmmmmiiiinnnn////ssssuuuuppppeeeerrrrvvvviiiissssoooorrrr////eeeemmmmppppllllooooyyyyeeeeeeeessss ttttoooo uuuusssseeee vvvveeeerrrrssssiiiioooonnnn
  278.      ((((5555////5555....000000004444////PPPPeeeerrrrllll iiiinnnnsssstttteeeeaaaadddd ooooffff ssssoooommmmeeee ooootttthhhheeeerrrr llllaaaannnngggguuuuaaaaggggeeee))))????
  279.  
  280.      If your manager or employees are wary of unsupported software, or
  281.      software which doesn't officially ship with your Operating System, you
  282.      might try to appeal to their self-interest.  If programmers can be more
  283.      productive using and utilizing Perl constructs, functionality,
  284.      simplicity, and power, then the typical manager/supervisor/employee may
  285.      be persuaded.  Regarding using Perl in general, it's also sometimes
  286.      helpful to point out that delivery times may be reduced using Perl, as
  287.      compared to other languages.
  288.  
  289.      If you have a project which has a bottleneck, especially in terms of
  290.      translation, or testing, Perl almost certainly will provide a viable, and
  291.      quick solution.  In conjunction with any persuasion effort, you should
  292.      not fail to point out that Perl is used, quite extensively, and with
  293.      extremely reliable and valuable results, at many large computer software
  294.      and/or hardware companies throughout the world.  In fact, many Unix
  295.      vendors now ship Perl by default, and support is usually just a news-
  296.      posting away, if you can't find the answer in the _c_o_m_p_r_e_h_e_n_s_i_v_e
  297.      documentation, including this FAQ.
  298.  
  299.      If you face reluctance to upgrading from an older version of perl, then
  300.      point out that version 4 is utterly unmaintained and unsupported by the
  301.      Perl Development Team.  Another big sell for Perl5 is the large number of
  302.      modules and extensions which greatly reduce development time for any
  303.      given task.  Also mention that the difference between version 4 and
  304.      version 5 of Perl is like the difference between awk and C++.  (Well, ok,
  305.      maybe not quite that distinct, but you get the idea.)  If you want
  306.      support and a reasonable guarantee that what you're developing will
  307.      continue to work in the future, then you have to run the supported
  308.      version.  That probably means running the 5.004 release, although 5.003
  309.      isn't that bad (it's just one year and one release behind).  Several
  310.      important bugs were fixed from the 5.000 through 5.002 versions, though,
  311.      so try upgrading past them if possible.
  312.  
  313. AAAAUUUUTTTTHHHHOOOORRRR AAAANNNNDDDD CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT
  314.      Copyright (c) 1997 Tom Christiansen and Nathan Torkington.  All rights
  315.      reserved.  See the _p_e_r_l_f_a_q manpage for distribution information.
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))                                                        PPPPEEEERRRRLLLLFFFFAAAAQQQQ1111((((1111))))
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.                                                                         PPPPaaaaggggeeee 6666
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.